package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lishuo
 * Date: 2023-03-26
 * Time: 15:28
 */
public class ThreadExample_Interrupted {
    public static boolean isQuite = false;
    public static void main(String[] args) {
        Thread t = new Thread(()->{
            while (!isQuite) {
                System.out.println("hello t");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("t线程终止");
        });

        t.start();
        // 在主线程中修改isQuite
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        isQuite = true;

    }
}
